package cn.dnui_001zjs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.dnui_001zjs.service.CategoryService;
import cn.dnui_001zjs.service.TripService;
import cn.dnui_001zjs.service.UserService;
import cn.dnui_001zjs.po.Category;
import cn.dnui_001zjs.po.Trip;

import java.util.*;

@Controller
public class IndexController {

	@Autowired
	private UserService service;
	
	@Autowired
	private TripService tripService;
	
	@Autowired
	private CategoryService categoryService;
	public IndexController() {
		// TODO Auto-generated constructor stub
	}
	@RequestMapping("/index/index.action")
	public String index(Model model){
		List<Category> catlist = categoryService.getCatList();
		model.addAttribute("catlist",catlist);
		
		List<Trip> triplist = tripService.getTripList();
		model.addAttribute("triplist",triplist);
		//model.addAttribute("hotnews", hotnewslist);
		return "index/index";
	}
	
	@RequestMapping("index/updateCat.action")
	public String update(Category category){
		try{
			Category cat=new Category();
			cat.setCid(1);
			cat.setCname("一日游");
			categoryService.updateCatById(cat);
	    return "forward:index.action";
		}catch(Exception e){
			return "redirect:index.action";
		}
		
		
	}

}
